package com.banzhi.shop.adapter;

import android.app.Activity;
import android.content.Context;


import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;


import com.banzhi.shop.R;
import com.banzhi.shop.data.Icons;

import com.banzhi.shop.entity.HomeGridView.IconBean;
import com.banzhi.shop.view.CircleImageView;
import com.squareup.picasso.Picasso;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2018/7/25.
 */

public class GroupGridViewAdapter extends ArrayAdapter<Icons> {
    private Context mContext;
    private int layouResourceId;
    private ArrayList<Icons> mGridData = new ArrayList<>();

    public GroupGridViewAdapter(Context context, int resource, ArrayList<Icons> objects) {
        super(context, resource, objects);
        this.mContext = context;
        this.layouResourceId = resource;
        this.mGridData = objects;
    }
    public void setGridData(ArrayList<Icons> mGridData) {
        this.mGridData = mGridData;
        notifyDataSetChanged();
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;

        if (convertView == null) {
            LayoutInflater inflater = ((Activity)mContext).getLayoutInflater();
            convertView = inflater.inflate(layouResourceId, parent, false);
            holder = new ViewHolder();
            holder.imageView = (CircleImageView) convertView.findViewById(R.id.civ_photo);
         //   holder.imageView2 =( ImageView)convertView.findViewById(R.id.iv_tuanzhang);
          //  holder.imageView3 =( ImageView)convertView.findViewById(R.id.iv_shafa);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        Icons item = mGridData.get(position);

        Picasso.with(mContext).load(item.getAvatar()).placeholder(R.mipmap.grid_item).into(holder.imageView);
  /*      if (position == 1) {

         *//*   holder.imageView2.setVisibility(View.VISIBLE);
            holder.imageView3.setVisibility(View.GONE);*//*

        } else {
            Picasso.with(mContext).load(item.getAvatar()).placeholder(R.mipmap.grid_item).into(holder.imageView);
           *//* holder.imageView2.setVisibility(View.GONE);
            holder.imageView3.setVisibility(View.VISIBLE);*//*
        }*/


        return convertView;
    }
    private class ViewHolder {

        CircleImageView imageView;
      /*  ImageView imageView2;
        ImageView imageView3;*/
    }
}
